<?php
/*
 * @Author: your name
 * @Date: 2019-12-23 16:29:39
 * @LastEditTime : 2020-01-03 13:43:39
 * @LastEditors  : Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /ahsmp_3/application/adminapiv3/controller/HostModuleRelation.php
 */
namespace app\adminapiv3\controller;

/**
 * @name: 主机模块关系管理
 * @Param: 
 * @Description: 
 * @Author: foo
 * @Date: 2019-12-02 14:51:56
 */
use app\adminapiv3\service;
class HostModuleRelation extends Base
{
    /**
     * @name: 未添加模块主机列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-12-02 14:53:12
     */
    function notAddedHostList ($module)
    {
        $filterData['name'] = $this->filterInput('name');
        $filterData['ip'] = $this->filterInput('ip');
        $filterData['online'] = $this->filterInput('online');
        $HostModuleRelation = new service\HostModuleRelation();
        $data = $HostModuleRelation->notAddedHostList($module, $filterData, $this->getLimit());

        $this->jsonOutPut($data);
    }

    /**
     * @name: 添加主机到模块
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-12-02 14:53:12
     */
    function addRelation ($module)
    {
        $this->filterInput('host_id*');
        $HostModuleRelation = new service\HostModuleRelation();
        $HostModuleRelation->toDo('addRelation', [$module]);
        $this->jsonOutPut([], true);
        
        $this->Async('Client', 'Modules');
    }

    /**
     * @name: 从模块中删除主机
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-12-02 15:13:16
     */
    function delRealtion ($module)
    {
        $this->filterInput('host_id*');
        $HostModuleRelation = new service\HostModuleRelation();
        $HostModuleRelation->toDo('delRelation', [$module]);
        $this->jsonOutPut([], true);

        $this->Async('Client', 'Modules');
    }
}